package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.AdministrativeDivision;
import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.community.model.Organization;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
/**
 * 目的地档案
 * @author zhangkailun
 * 
 * 模型评审：新增模型，wulina 2016-09-07
 *
 */
@Entity
@Table(name = "travel_destination")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = { @CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "organization:organization") })
public class Destination extends BaseModel{

	private static final long serialVersionUID = -7227891219571836184L;

	/** 主键*/
	@Id
	@In
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	private Long pkDestination;
	
	/** 创建机构*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkOrganization")
    @IndexedEmbedded(depth = 1)
	private Organization organization;
	
	/** 目的地名称*/
	@Column
	@Field
	private String name;
	
	/** 省/市/区（县）*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="pkAddress")
	@IndexedEmbedded(depth = 1)
	private AdministrativeDivision address;
	
	/** 乡（镇）/社区*/
	@Column
	@Field
	private String street;
	
	/** 联系人*/
	@Column
	@Field
    private String contact;
	
	/** 联系电话*/
	@Field
	@Column
	private String phone;

	/** 目的地介绍*/
	@Field
	@Column(length = 1023)
    private String introduce;
	
	/** 备注 */
	@Field
	@Column(length = 1023)
	private String description;
		
	/** 状态*/
	@Enumerated(EnumType.STRING)
	@Field
	@In
	@FieldBridge(impl = EnumBridge.class)
	private Status status;
		
	@Version
	private Integer version;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum Status {
		Setting("启用"), BlockUp("停用");

		private String display;

		Status(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}

	public Long getPkDestination() {
		return pkDestination;
	}

	public void setPkDestination(Long pkDestination) {
		this.pkDestination = pkDestination;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public AdministrativeDivision getAddress() {
		return address;
	}

	public void setAddress(AdministrativeDivision address) {
		this.address = address;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}


	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
	

}
